#ifndef LOGUTIL_H
#define LOGUTIL_H

#include <android/log.h>
#include <sys/time.h>

#define  LOG_TAG "opengldemo"

#define  LOG_DEBUG(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#define  LOGCATE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)

#define IS_RELEASE_VERSION

#ifdef IS_RELEASE_VERSION
#define FUN_BEGIN_TIME(FUN)
#define FUN_END_TIME(FUN)
#else
#define FUN_BEGIN_TIME(FUN) {\
    LOG_DEBUG("%s:%s start", __FILE__, FUN); \
    long long t0 = GetCurrentTime();

#define FUN_END_TIME(FUN) \
    long long t1 = GetCurrentTime(); \
    LOG_DEBUG("%s:%s cost time %ldms", __FILE__, FUN, (long)(t1-t0));}
#endif

static long long GetCurrentTime() {
#if defined(__linux__)
    struct timeval time;
    gettimeofday(&time, NULL);
    long long curTime = ((long long) (time.tv_sec)) * 1000 + time.tv_usec / 1000;
    return curTime;
#elif defined(_WIN32)
    return  (long long)timeGetTime();
#endif
}

#endif